package sampletest;

import java.util.ArrayList;
import java.util.List;

public class Shelf {

    private int maxCapacity;
    List<Album> albumList = new ArrayList<Album>();

    public Shelf(int maxCapacity) {
        this.maxCapacity = maxCapacity;
    }

    public void addAlbum(Album a){
        if (albumList.size() < maxCapacity){
            albumList.add(a);
        } else {
            throw new RuntimeException("Shelf if full");
        }

    }

    public List<Album> getAlbumsByGroup(String group){
        List<Album> subList = new ArrayList<Album>();
        for (Album album : albumList) {
            if (album.getGroup().equals(group)){
                subList.add(album);
            }
        }
        return subList;
    }
}
